﻿<%@ Page Title="Topic Groups" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true"
    CodeFile="Groups.aspx.cs" Inherits="Topics_Groups" %>

<%@ Register TagPrefix="uc" TagName="Menu" Src="~/Topics/Menu.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phActions" runat="Server">
    <asp:LinkButton ID="lnkAdd" Text="Add New Group" runat="server" 
        onclick="lnkAdd_Click" />
    <asp:LinkButton ID="lnkRefresh" Text="Refresh" style="display:none" runat="server" 
        onclick="lnkRefresh_Click" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phSubMenu" runat="Server">
    <uc:Menu ID="menu" runat="server" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="phMain" runat="Server">
    <script type="text/javascript">
        function editItem(id) {
            var oManager = GetRadWindowManager();
            var oWnd = oManager.GetWindowByName("winUpdate");

            var url = oWnd.GetUrl();

            if (url.indexOf("&Id=") == -1 && url.indexOf("?Id=")) {
                url += url.indexOf("?") == -1 ? "?" : "&";
                url += "Id="
                url += id;
            }
            else if (url.indexOf("&Id=") > -1) {
                url = url.substring(0, url.indexOf("&Id=") + 4);
                url += id;
            }
            else if (url.indexOf("?Id=") > -1) {
                url = url.substring(0, url.indexOf("?Id=") + 4);
                url += id;
            }

            oWnd.SetUrl(url);
            oWnd.Show();      
            return false;

        }

        var lnkRefreshId = "";
        function closePopUp(oWnd) {
            if (oWnd.argument) {
                //get the transferred arguments
                if (oWnd.argument.saved) {
                    __doPostBack(lnkRefreshId, "");
                }
                else {
                }
            }
        }
    </script>
    <ajax:Accordion ID="accordian" SelectedIndex="-1" ToolTip="Click header to show and hide info" RequireOpenedPane="false" HeaderCssClass="header" ContentCssClass="content" CssClass="expandingDetails" runat="server">
        <Panes>
            <ajax:AccordionPane>
                <Header>Topic Groups</Header>
                <Content>
                    Topic Groups allow topics to be seperated into functional groups.
                </Content>
            </ajax:AccordionPane>
        </Panes>
    </ajax:Accordion>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Transparency="1" runat="server" Height="75px"
        Width="75px">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="gvGroups" runat="server" AutoGenerateColumns="False" 
        DataSourceID="dsGroups" GridLines="None" AllowAutomaticInserts="True" 
        AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" >
        <MasterTableView EditMode="PopUp" DataSourceID="dsGroups" 
            ShowHeadersWhenNoRecords="true" AllowAutomaticInserts="true" 
            InsertItemDisplay="Bottom" DataKeyNames="Id,ConcurencyId">
            <NoRecordsTemplate>
                No Topic Groups have been set up.
            </NoRecordsTemplate>

<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn Visible="False" Resizable="False">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" />
                <telerik:GridBoundColumn DataField="Path" HeaderText="Path" />
                <telerik:GridBoundColumn DataField="Notes" HeaderText="Notes" />
                <telerik:GridBoundColumn DataField="TopicCount" HeaderText="Topics" />
                <telerik:GridBoundColumn DataField="Created" HeaderText="Created" />
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <a href="#" onclick="return editItem(<%#DataBinder.Eval(Container.DataItem, "Id")%>)">Edit</a>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" Text="Delete" ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to delete this Topic Group?" CommandName="Delete" />
            </Columns>

<EditFormSettings>
<PopUpSettings ScrollBars="None"></PopUpSettings>
</EditFormSettings>
        </MasterTableView>
        <PagerStyle Mode="Slider" />
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="winManager" OnClientClose="closePopUp" KeepInScreenBounds="true" runat="server">
        <Windows>
            <telerik:RadWindow ID="winInsert" Width="800" Height="600" OpenerElementID='<%=lnkAdd.ClientID %>' Behaviors="Maximize,Close" Title="Add New Topic Group" Modal="true" NavigateUrl="GroupEdit.aspx?Mode=Insert" VisibleStatusbar="false" runat="server">
            </telerik:RadWindow>
            <telerik:RadWindow ID="winUpdate" Width="800" Height="600" Behaviors="Maximize,Close" Title="Edit Topic Group" Modal="true" NavigateUrl="GroupEdit.aspx?Mode=Edit" VisibleStatusbar="false" runat="server">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <acms:TopicGroupDataSource ID="dsGroups" runat="server" EnablePaging="False" 
        onselectdata="dsGroups_SelectData" onupdatingdata="dsGroups_UpdatingData">
    </acms:TopicGroupDataSource>
    <telerik:RadAjaxManager runat="server" 
        DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="lnkRefresh">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gvGroups" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="gvGroups">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gvGroups" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>
